# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2022-2025, The OpenROAD Authors
load("//test:regression.bzl", "regression_test")

# From CMakeLists.txt or_integration_tests(TESTS
COMPULSORY_TESTS = [
    "add_constraint1",
    "add_constraint2",
    "add_constraint3",
    "add_constraint4",
    "add_constraint5",
    "add_constraint6",
    "add_constraint7",
    "add_constraint8",
    "add_constraint9",
    "add_constraint10",
    "add_constraint11",
    "add_constraint12",
    "add_constraint13",
    "add_constraint14",
    "add_constraint15",
    "add_constraint16",
    "add_constraint17",
    "add_constraint18",
    "add_constraint_debug",
    "add_constraint_error1",
    "add_constraint_error2",
    "add_constraint_error3",
    "add_constraint_error4",
    "add_constraint_error5",
    "add_constraint_error6",
    "add_constraint_error7",
    "add_constraint_error8",
    "add_constraint_error9",
    "annealing1",
    "annealing2",
    "annealing3",
    "annealing4",
    "annealing_constraint1",
    "annealing_constraint2",
    "annealing_constraint3",
    "annealing_constraint4",
    "annealing_constraint5",
    "annealing_constraint6",
    "annealing_constraint7",
    "annealing_constraint8",
    "annealing_large_groups1",
    "annealing_large_groups2",
    "annealing_mirrored1",
    "annealing_mirrored2",
    "annealing_mirrored3",
    "annealing_mirrored4",
    "annealing_mirrored5",
    "blocked_region",
    "cells_not_placed",
    "exclude1",
    "exclude2",
    "exclude3",
    "exclude4",
    "gcd",
    "group_pins1",
    "group_pins2",
    "group_pins3",
    "group_pins4",
    "group_pins5",
    "group_pins6",
    "group_pins7",
    "group_pins8",
    "group_pins9",
    "group_pins10",
    "group_pins11",
    "group_pins12",
    "group_pins_error1",
    "group_pins_warn1",
    "invalid_layer",
    "large_groups1",
    "large_groups2",
    "large_groups3",
    "large_groups4",
    "macro_not_placed",
    "macro_not_placed_random",
    "min_dist_in_tracks1",
    "min_dist_in_tracks2",
    "multiple_calls",
    "multi_layers",
    "multi_track_pattern1",
    "multi_track_pattern2",
    "multi_track_pattern3",
    "multi_track_pattern4",
    "multi_track_pattern5",
    "no_instance_pins",
    "no_pins",
    "no_tracks",
    "on_grid",
    "partial_tracks",
    "partial_tracks_error",
    "pin_extension",
    "pin_length",
    "pin_length_error",
    "pin_thick_multiplier",
    "place_pin1",
    "place_pin2",
    "place_pin3",
    "place_pin4",
    "place_pin5",
    "place_pin6",
    "place_pin7",
    "place_pin_error1",
    "place_pin_error2",
    "place_pin_error3",
    "random1",
    "random2",
    "random3",
    "random4",
    "random5",
    "random6",
    "random7",
    "random8",
    "random9",
    "top_layer1",
    "top_layer2",
    "top_layer3",
    "top_layer4",
    "top_layer5",
    "top_layer6",
    "top_layer7",
    "top_layer_error",
    "top_layer_error2",
    "write_pin_placement1",
    "write_pin_placement2",
    "write_pin_placement3",
    "write_pin_placement4",
    "write_pin_placement5",
    "write_pin_placement6",
]

# Disabled in CMakeLists.txt
MANUAL_TESTS = [
    "ppl_man_tcl_check",
    "ppl_readme_msgs_check",
]

ALL_TESTS = COMPULSORY_TESTS + MANUAL_TESTS

filegroup(
    name = "regression_resources",
    # Dependencies could be specified more narrowly per test case,
    # but at least it is not a glob of everything and there are
    # per test glob patterns below.
    srcs = glob(
        ["**/*"],
        exclude = [test_name + ".*" for test_name in ALL_TESTS],
    ),
)

[
    filegroup(
        name = test_name + "_resources",
        srcs = [":regression_resources"] + glob(
            [
                test_name + ".*",
            ],
        ) + {
            "gcd": [],
            "blocked_region": [],
            "large_groups1": [],
            "group_pins3": [],
            "multi_track_pattern1": ["multi_track_pattern2.lef"],
            "multi_track_pattern2": ["multi_track_pattern1.lef"],
            "pin_length_error": ["on_grid.def"],
            "macro_not_placed_random": [
                "macro_not_placed.def",
                "blocked_region.lef",
            ],
            "write_pin_placement6": ["write_pin_placement5.def"],
        }.get(
            test_name,
            [
                "gcd.def",
                "blocked_region.lef",
                "blocked_region.def",
                "large_groups1.def",
                "group_pins3.def",
                "multi_track_pattern1.lef",
                "multi_track_pattern2.lef",
            ],
        ),
    )
    for test_name in ALL_TESTS
]

[
    regression_test(
        name = test_name,
        data = [":" + test_name + "_resources"],
        tags = [] if test_name in COMPULSORY_TESTS else ["manual"],
        visibility = ["//visibility:public"],
    )
    for test_name in ALL_TESTS
]
